package com.ddone.service.impl;

import com.ddone.bean.User;
import com.ddone.mapper.UserMapper;
import com.ddone.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ddone
 * @date 2024/3/24-14:21
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(User user) {
        return userMapper.selectByNameAndPassword(user.getUAccount(), user.getUPassword());
    }

    @Override
    public int save(User user) {
        return userMapper.insert(user);
    }

    @Override
    public List<User> list() {
        return userMapper.selectAll();
    }

    @Override
    public int delete(String uId) {
        return userMapper.deleteById(uId);
    }

    @Override
    public User getById(String uid) {
        return userMapper.selectById(uid);
    }

    @Override
    public int update(User user) {
       return userMapper.update(user);
    }

    @Override
    public List<User> search(String keyword) {
        return userMapper.search(keyword);
    }
}
